#include "../syncup-service.h"
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-bindings.h>

int main()
{
    guint result;
    GError *err = NULL;
    GMainLoop *loop;
    DBusGConnection *conn;
    DBusGProxy *proxy;
    GObject *gobj;

    g_type_init();
    if (!g_thread_supported()) {
        g_thread_init(NULL);
    }
    dbus_g_thread_init();

    loop = g_main_loop_new(NULL, FALSE);
    conn = dbus_g_bus_get(DBUS_BUS_SESSION, &err);
    proxy = dbus_g_proxy_new_for_name(conn, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
            DBUS_INTERFACE_DBUS);

    org_freedesktop_DBus_request_name (proxy, SYNCUP_SERVICE_DBUS_NAME,
            DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &err);

    gobj = g_object_new(SYNCUP_TYPE_SERVICE, NULL);
    dbus_g_connection_register_g_object(conn, SYNCUP_SERVICE_DBUS_PATH, gobj);

    g_main_loop_run(loop);

    return 0;
}
